from flask import Flask

from approval_service.approval.controller import advance_approval_blueprint, approval_blueprint, \
    reimbursement_approval_fi_blueprint, reimbursement_approval_ma_blueprint, travel_approval_blueprint
from commons.controller.global_exception_handler_controller import GlobalExceptionHandlerController


def create_app():
    app = Flask(__name__)

    GlobalExceptionHandlerController.register_global_exception_handlers(app)
    app.register_blueprint(advance_approval_blueprint, url_prefix='/advanceApproval')
    app.register_blueprint(approval_blueprint, url_prefix='/approval')
    app.register_blueprint(reimbursement_approval_fi_blueprint, url_prefix='/reimbursementApprovalFi')
    app.register_blueprint(reimbursement_approval_ma_blueprint, url_prefix='/reimbursementApprovalMa')
    app.register_blueprint(travel_approval_blueprint, url_prefix='/travelApproval')

    return app
